# $Id$
# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Andrea Scarpino <andrea@archlinux.org>

pkgname=kdelibs4support
pkgver=5.38.0
pkgrel=1
pkgdesc='Porting aid from KDELibs4'
arch=('i686' 'x86_64')
url='https://community.kde.org/Frameworks'
license=('LGPL')
depends=('kunitconversion' 'kitemmodels' 'kemoticons' 'kded' 'kparts')
makedepends=('extra-cmake-modules' 'kdoctools' 'qt5-tools' 'networkmanager' 'perl-uri' 'python' 'kdesignerplugin')
groups=('kf5-aids')
replaces=('kde4support')
conflicts=('kde4support')
source=("https://download.kde.org/stable/frameworks/${pkgver%.*}/portingAids/${pkgname}-${pkgver}.tar.xz"{,.sig}
        kdelibs4support-openssl-1.1.patch)
sha256sums=('f72aac163070bd116a112b7918a71d9dc79f945b19e5f449e55704e1e37f741b'
            'SKIP'
            '0ab7d942145fb714d622c9049a060b8451a2e5315c2d8a91528583ebb6f20487')
validpgpkeys=(53E6B47B45CEA3E0D5B7457758D0EE648A48B3BB) # David Faure <faure@kde.org>

prepare() {
  mkdir -p build

# fix build with OpenSSL 1.1 (OpenMandriva)
  cd $pkgname-$pkgver
  patch -p1 -i ../kdelibs4support-openssl-1.1.patch
}

build() {
  cd build
  cmake ../${pkgname}-${pkgver} \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DKDE_INSTALL_LIBDIR=lib \
    -DKDE_INSTALL_LIBEXECDIR=lib \
    -DBUILD_TESTING=OFF
  make
}

package() {
  cd build
  make DESTDIR="${pkgdir}" install

# cert bundle seems to be hardcoded
# link it to the one from ca-certificates
  rm -f "$pkgdir"/usr/share/kf5/kssl/ca-bundle.crt
  ln -sf /etc/ssl/certs/ca-certificates.crt "${pkgdir}"/usr/share/kf5/kssl/ca-bundle.crt
}
